package cn.hznc.controller.icabinet;

import cn.hznc.controller.service.icabinet.IcabinetService;
import cn.hznc.domain.request.icabinet.*;
import cn.hznc.domain.request.inventory.TooLReturnChartReq;
import cn.hznc.domain.request.toolAnalyze.IntelligentToolChartReq;
import cn.hznc.domain.response.ResponseBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * @Author：Administrator
 * @Date：2023/11/6 15:09
 */
@RestController
@Slf4j
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/icabinet")
public class IcabinetRecordController{

    @Autowired
    private IcabinetService icabinetService;

    @RequestMapping(value = "/recordGroupMachineToolIndex", method = RequestMethod.POST)
    public ResponseBody recordGroupMachineToolIndex(@RequestBody RecordMachineToolIndexReq recordMachineToolIndexReq){
        return ResponseBody.success(icabinetService.recordGroupMachineToolIndex(recordMachineToolIndexReq));
    }

    @RequestMapping(value = "/recordGroupMachineTool", method = RequestMethod.POST)
    public ResponseBody recordGroupMachineTool(@RequestBody RecordMachineToolIndexReq recordMachineToolIndexReq){
        return ResponseBody.success(icabinetService.recordGroupMachineTool(recordMachineToolIndexReq));
    }

    @RequestMapping(value = "/searchRecord", method = RequestMethod.POST)
    public ResponseBody searchRecord(@RequestBody SearchRecordReq searchRecordReq){
        return ResponseBody.success(icabinetService.searchRecord(searchRecordReq));
    }

    @RequestMapping(value = "/qryMachineToolNameGroup", method = RequestMethod.GET)
    public ResponseBody qryMachineToolNameGroup(){
        return ResponseBody.success(icabinetService.qryMachineToolNameGroup());
    }

    @RequestMapping(value = "/queryIntelligentToolChartByDay", method = RequestMethod.POST)
    public ResponseBody queryIntelligentToolChartByDay(@RequestBody IcabinetChartReloadReq icabinetChartReloadReq){
        try {
            return ResponseBody.success(icabinetService.queryIntelligentToolChartByDay(icabinetChartReloadReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/queryToolReturnChartByDay", method = RequestMethod.POST)
    public ResponseBody queryToolReturnChartByDay(@RequestBody TooLReturnChartReq tooLReturnChartReq){
        try {
            return ResponseBody.success(icabinetService.queryToolReturnChartByDay(tooLReturnChartReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryIntelligentToolChartByMonth", method = RequestMethod.POST)
    public ResponseBody qryIntelligentToolChartByMonth(@RequestBody IcabinetChartReloadReq IcabinetChartReloadReq){
        try {
            return ResponseBody.success(icabinetService.qryIntelligentToolChartByMonth(IcabinetChartReloadReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryChartByMonth", method = RequestMethod.POST)
    public ResponseBody qryChartByMonth(@RequestBody IcabinetChartReq icabinetChartReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByMonth(icabinetChartReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryChartByMonthRecordNumberReload", method = RequestMethod.POST)
    public ResponseBody qryChartByMonthRecordNumberReload(@RequestBody IcabinetChartReloadReq icabinetChartReloadReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByMonthRecordNumberReload(icabinetChartReloadReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryChartByMonthRecordPriceReload", method = RequestMethod.POST)
    public ResponseBody qryChartByMonthRecordPriceReload(@RequestBody IcabinetChartReloadReq icabinetChartReloadReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByMonthRecordPriceReload(icabinetChartReloadReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryChartByMonthRecordNumber", method = RequestMethod.POST)
    public ResponseBody qryChartByMonthRecord(@RequestBody IcabinetChartReq icabinetChartReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByMonthRecord(icabinetChartReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/qryChartByMonthRecordPrice", method = RequestMethod.POST)
    public ResponseBody qryChartByMonthRecordPrice(@RequestBody IcabinetChartReq icabinetChartReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByMonthRecordPrice(icabinetChartReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    /**
     * 智能柜人员取料分组统计（1）
     * @return
     */
    @RequestMapping(value = "/recordGroupOperatorIndex", method = RequestMethod.POST)
    public ResponseBody recordGroupOperatorIndex(@RequestBody RecordGroupOperatorIndexReq recordGroupOperatorIndexReq){
        return ResponseBody.success(icabinetService.recordGroupOperatorIndex(recordGroupOperatorIndexReq));
    }

    /**
     * 智能柜人员取料分组统计（2）
     * @return
     */
    @RequestMapping(value = "/recordGroupOperator", method = RequestMethod.POST)
    public ResponseBody recordGroupOperator(@RequestBody RecordGroupOperatorIndexReq recordGroupOperatorIndexReq){
        return ResponseBody.success(icabinetService.recordGroupOperator(recordGroupOperatorIndexReq));
    }

    /**
     * 智能柜craft取料分组统计（1）
     * @return
     */
    @RequestMapping(value = "/recordGroupCraftIndex", method = RequestMethod.POST)
    public ResponseBody recordGroupCraftIndex(@RequestBody RecordGroupCraftIndexReq recordGroupCraftIndexReq){
        return ResponseBody.success(icabinetService.recordGroupCraftIndex(recordGroupCraftIndexReq));
    }

    /**
     * 智能柜人员取料分组统计（2）
     * @return
     */
    @RequestMapping(value = "/recordGroupCraft", method = RequestMethod.POST)
    public ResponseBody recordGroupCraft(@RequestBody RecordGroupCraftIndexReq recordGroupCraftIndexReq){
        return ResponseBody.success(icabinetService.recordGroupCraft(recordGroupCraftIndexReq));
    }

    @RequestMapping(value = "/qryChartByDay", method = RequestMethod.POST)
    public ResponseBody qryChartByDay(@RequestBody IcabinetChartReq icabinetChartReq){
        try {
            return ResponseBody.success(icabinetService.qryChartByDay(icabinetChartReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }

    @RequestMapping(value = "/icabinetDeadStock", method = RequestMethod.POST)
    public ResponseBody icabinetDeadStock(@RequestBody IcabinetDeadStockReq icabinetDeadStockReq){
        return ResponseBody.success(icabinetService.icabinetDeadStock(icabinetDeadStockReq));
    }


}
